package com.prolestar.web.controller.territorialMedia;

import com.prolestar.common.annotation.Log;
import com.prolestar.common.core.controller.BaseController;
import com.prolestar.common.core.domain.AjaxResult;
import com.prolestar.common.core.page.TableDataInfo;
import com.prolestar.common.enums.BusinessType;
import com.prolestar.territorialMedia.domain.PsVmediaPerson;
import com.prolestar.territorialMedia.domain.TerritorialMediaDTO;
import com.prolestar.territorialMedia.service.IterritorialMediaService;
import com.prolestar.util.MySetPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 属地自媒体
 */
@RestController
@RequestMapping("/territorialMedia")
public class TerritorialMediaController extends BaseController {

    @Autowired
    private IterritorialMediaService territorialMediaService;


    /**
     * 全国地区查询
     */
    @GetMapping("/areaList")
    public Object areaList(){
       return territorialMediaService.areaList();
    }



    /**
     * 自媒体列表查询
     * @param psVmediaPerson
     * @return
     */
    @GetMapping("/mediaList")
    public TableDataInfo mediaList(PsVmediaPerson psVmediaPerson){
        List<PsVmediaPerson> list = territorialMediaService.mediaList(psVmediaPerson);
        return MySetPage.mySetPage(list);
    }

    /**
     * 获取自媒体详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(territorialMediaService.selectPsVmediaPersonById(id));
    }


    /**
     * 新增属地自媒体
     */
    @Log(title = "自媒体", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TerritorialMediaDTO TerritorialMediaDTO)
    {
        return territorialMediaService.insertPsVmediaPerson(TerritorialMediaDTO);
    }

    /**
     * 修改属地自媒体
     */
    @Log(title = "自媒体", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TerritorialMediaDTO TerritorialMediaDTO)
    {
        return territorialMediaService.updatePsVmediaPerson(TerritorialMediaDTO);
    }

    /**
     * 删除属地自媒体
     */
    @Log(title = "自媒体", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return territorialMediaService.deletePsVmediaPerson(ids);
    }


    /**
     * 重点关注
     */
    @PostMapping("/UpdateAttention")
    public AjaxResult UpdateAttention(@RequestBody PsVmediaPerson psVmediaPerson)
    {
        return territorialMediaService.UpdateAttention(psVmediaPerson);
    }





}
